package com.aftersale.demo.mapper;

import com.aftersale.demo.entity.Project;
import com.aftersale.demo.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
*@author  空
*@date    2023/10/23 20:31
*@desc
*/
public interface UserMapper extends BaseMapper<User> {
    /**
     * @description: 检查注册用户名是否已存在
     * @param: user
     * @return:  User
     * @author 空
     */
    @Select("select * from user where user_name=#{userName}")
    User exits(User user);
    /**
     * @description: 用户注册接口
     * @param: user
     * @return:  User
     * @author 空
     */
    @Insert("insert into user(user_name,password,real_name,email) values(#{userName},#{password},#{realName},#{email})")
    void register(User user);
    @Update("UPDATE `user` SET `password`=#{password} WHERE user_name=#{userName}")
    void forget(User user);

    Page<User> getUser(Page page);

    List<User> selectRoleUser(int roleId);

    void updateInfo(User user);

    @Update("UPDATE `user` SET `password`=#{password} WHERE id=#{id}")
    void updatePassword(User user);

    Page<Project> getUserProject(int userId, Page page);

    void deleteproject(int userId, int projectId);

    Integer haveProject(int userId, int projectId);

    void addUserProject(int userId, int projectId);

    void updateRemind(int projectId);

    Page<Project> selectUserProject(int userId, String name, Page<Object> objectPage);
}




